// 模拟数据生成器

// 定义所需的类型接口
interface VehicleStatus {
  speed: number;
  speedLimit: number;
  gear: 'P' | 'R' | 'N' | 'D';
  battery: number;
  temperature: number;
  autonomousMode: boolean;
  emergencyStop: boolean;
  cruiseSpeed?: number;
}

interface NavigationInfo {
  destination: string;
  distance: number;
  eta: number;
  currentStreet: string;
  nextTurn: string;
  turnDistance: number;
}

interface ModuleStatus {
  camera: 'online' | 'offline' | 'warning';
  lidar: 'online' | 'offline' | 'warning';
  radar: 'online' | 'offline' | 'warning';
  gps: 'online' | 'offline' | 'warning';
  imu: 'online' | 'offline' | 'warning';
  can: 'online' | 'offline' | 'warning';
  perception: 'online' | 'offline' | 'warning';
  planning: 'online' | 'offline' | 'warning';
  control: 'online' | 'offline' | 'warning';
}

interface SystemMessage {
  id: string;
  type: 'info' | 'warning' | 'error' | 'success';
  title: string;
  message: string;
  timestamp: Date;
  acknowledged: boolean;
}

interface UserRole {
  type: 'passenger' | 'safety_officer';
  name: string;
  permissions: string[];
}

interface DetectedObject {
  id: string;
  type: 'pedestrian' | 'vehicle' | 'bicycle' | 'animal' | 'unknown';
  position: { x: number; y: number; z: number };
  confidence: number;
  distance: number;
  velocity: number;
}

interface ControlSettings {
  volume: number;
  brightness: number;
  language: 'zh' | 'en';
  theme: 'light' | 'dark' | 'auto';
  fontSize?: 'small' | 'medium' | 'large' | 'xlarge';
}

interface RoutePoint {
  id: string;
  name: string;
  latitude: number;
  longitude: number;
  type: 'pickup' | 'destination' | 'waypoint';
  estimatedTime: Date;
}

export const generateMockVehicleStatus = (): VehicleStatus => ({
  speed: Math.floor(Math.random() * 60) + 20,
  speedLimit: 50,
  gear: 'D',
  battery: Math.floor(Math.random() * 30) + 70,
  temperature: Math.floor(Math.random() * 10) + 20,
  autonomousMode: true,
  emergencyStop: false,
  cruiseSpeed: 45,
});

export const generateMockNavigationInfo = (): NavigationInfo => ({
  destination: '软通动力大厦',
  distance: 2.5,
  eta: 8,
  currentStreet: '滨海大道',
  nextTurn: '右转进入科技园',
  turnDistance: 300,
});

export const generateMockModuleStatus = (): ModuleStatus => ({
  camera: Math.random() > 0.9 ? 'warning' : 'online',
  lidar: Math.random() > 0.95 ? 'offline' : 'online',
  radar: Math.random() > 0.9 ? 'warning' : 'online',
  gps: 'online',
  imu: 'online',
  can: Math.random() > 0.95 ? 'warning' : 'online',
  perception: 'online',
  planning: 'online',
  control: 'online',
});

export const generateMockSystemMessages = (): SystemMessage[] => [
  {
    id: '1',
    type: 'info',
    title: '自动驾驶模式激活',
    message: '车辆已进入自动驾驶模式，请系好安全带',
    timestamp: new Date(Date.now() - 1000 * 60 * 5),
    acknowledged: false,
  },
  {
    id: '2',
    type: 'warning',
    title: '前方施工',
    message: '检测到前方路段施工，请减速行驶',
    timestamp: new Date(Date.now() - 1000 * 60 * 3),
    acknowledged: false,
  },
];

export const generateMockUserRole = (): UserRole => ({
  type: 'passenger',
  name: '乘客',
  permissions: ['view_status', 'emergency_call', 'emergency_stop'],
});

export const generateMockDetectedObjects = (): DetectedObject[] => [
  {
    id: '1',
    type: 'pedestrian',
    position: { x: 10, y: 5, z: 0 },
    confidence: 0.95,
    distance: 15,
    velocity: 1.2,
  },
  {
    id: '2',
    type: 'vehicle',
    position: { x: -8, y: 20, z: 0 },
    confidence: 0.88,
    distance: 25,
    velocity: 12.5,
  },
];

export const generateMockControlSettings = (): ControlSettings => ({
  volume: 70,
  brightness: 80,
  language: 'zh',
  theme: 'dark',
  fontSize: 'medium',
});

export const generateMockRoute = (): RoutePoint[] => [
  {
    id: '1',
    name: '企鹅岛地铁站',
    latitude: 22.5406,
    longitude: 113.9347,
    type: 'pickup',
    estimatedTime: new Date(Date.now() - 1000 * 60 * 10),
  },
  {
    id: '2',
    name: '科技园',
    latitude: 22.5392,
    longitude: 113.9374,
    type: 'waypoint',
    estimatedTime: new Date(Date.now() + 1000 * 60 * 5),
  },
  {
    id: '3',
    name: '软通动力大厦',
    latitude: 22.5363,
    longitude: 113.9354,
    type: 'destination',
    estimatedTime: new Date(Date.now() + 1000 * 60 * 15),
  },
];
